package com.tscnd.core.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tscnd.core.comon.TargetDataSource;
import com.tscnd.core.dao.UserMapper;
import com.tscnd.core.entity.User;
import com.tscnd.core.service.IUserService;

@Service("userService")
public class UserServiceImpl implements IUserService {
	
	@Autowired
	private UserMapper userMapper;
	
	@TargetDataSource(name="ds2")
	@Override
	public User findByName(String name) {
		return userMapper.findByName(name);
	}
	
	@Transactional
	@TargetDataSource(name="ds1")
	@Override
	public void insert(User user) throws Exception {
		int i=userMapper.insertByUser(user);
		if(i<=0){
			throw new RuntimeException("添加用户异常！");
		}else{
			//throw new RuntimeException("添加用户异常！");
		}
	}
	

}
